# -*- coding: utf-8 -*-
# @Time    : 2022/1/11 14:04
# @Author  : mzp
# @Email   : 2609404548@qq.com
# @File    : tjrz_page.py
# @Software: PyCharm

"""进行添加日志页面"""
from pages.base_page import BasePage

from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
class TjRz(BasePage):

    xjjrz_locator = (By.CSS_SELECTOR, "body > div.container > div.row > div:nth-child(2) > div > a")#点击新建日志按钮

    rzbt_locator = (By.CSS_SELECTOR, "body > div.container > div.row > div > form > table > tbody > tr:nth-child(2) > "
                                     "td:nth-child(2) > input") #标题
    rzlxxz_locator = (By.XPATH, "/html/body/div[5]/div[2]/div/form/table/tbody/tr[3]/td[2]/input[3]") #选择日志类型

    rzsj_locator = (By.CSS_SELECTOR, "#business_name") #选择日志类型
    xzsj_tobody_locator = (By.ID, 'data')  # 选择择商机tbody
    sjok_locator = (By.XPATH, "/html/body/div[7]/div[3]/div/button[1]/span")#选择商机的ok按钮

    xgrw_locator = (By.CSS_SELECTOR, "#task_name")  # 任务框
    rwtobody_locator = (By.XPATH, '//*[@id="data"]')#任务表的body
    rwok_locator = (By.XPATH, "/html/body/div[8]/div[3]/div/button[1]/span")#任务的ok按钮

    xxcp_locator = (By.CSS_SELECTOR, "#product_name") #营销产品框
    xxcp_tobody_locator = (By.XPATH, '//*[@id="data"]') #营销产品的body
    xxok_locator = (By.XPATH, "/html/body/div[9]/div[3]/div/button[1]/span") #产品的ok

    kh_locator = (By.CSS_SELECTOR, "#customer_name")#客户框
    kh_tobody_locator = (By.CSS_SELECTOR, '#datas')#客户表格body
    ku_td_locator = (By.CSS_SELECTOR, "#datas > tr:nth-child(4) > td:nth-child(1) > input[type=radio]:nth-child(1)")


    kuok_locator = (By.XPATH, "/html/body/div[10]/div[3]/div/button[1]/span") #客户ok按钮

    zs_locator = (By.CSS_SELECTOR, ".ke-edit-iframe") #内容

    rzbc_locator = (By.XPATH, "/html/body/div[5]/div[2]/div/form/table/tfoot/tr/td[2]/input[1]")#保存按钮


    def xjrz(self):    #点击新建按钮
        self.driver.find_element(*self.xjjrz_locator).click()
    def rzbtql(self,neirong):    #主题处理
        self.driver.find_element(*self.rzbt_locator).clear()
        self.driver.find_element(*self.rzbt_locator).send_keys(Keys.BACK_SPACE)
        self.driver.find_element(*self.rzbt_locator).send_keys(neirong)
    def xlxz(self):  #日志类型选择
        self.driver.find_element(*self.rzlxxz_locator).click()
    def sjdj(self):  #点击商机选择框
        self.driver.find_element(*self.rzsj_locator).click()
    def  sjbg(self,wyu): #对商机表格内容进行选择

        table = self.driver.find_element(*self.xzsj_tobody_locator)
        trs = table.find_elements(By.TAG_NAME, 'tr')
        for i in trs:
            tds = i.find_elements(By.TAG_NAME, 'td')
            if tds[1].text == wyu:
                tds[0].find_element(By.TAG_NAME, 'input').click()

    def sjok(self):
        self.driver.find_element(*self.sjok_locator).click() #商机ok按钮

    def rwxzk(self):
        self.driver.find_element(*self.xgrw_locator).click()    # 选择任务选择框

    def rwbg(self):

        table = self.driver.find_element(*self.rwtobody_locator)

        trs = table.find_elements(By.TAG_NAME, 'tr')
        for i in trs:
            tds = i.find_elements(By.TAG_NAME, 'td')
            if tds[1].text == '和尚的一天':
                tds[0].find_element(By.TAG_NAME, 'input').click()
    def rwok(self):


        self.driver.find_element(*self.rwok_locator).click()       # 选中任务ok

    def cpk(self):     #选择产品选择框
        self.driver.find_element(*self.xxcp_locator).click()
    def cpbg(self):

        table = self.driver.find_element(*self.xxcp_tobody_locator)          # 营销产品表格

        trs = table.find_elements(By.TAG_NAME, 'tr')
        for i in trs:
            tds = i.find_elements(By.TAG_NAME, 'td')
            if tds[1].text == '杀人，海洛因':
                tds[0].find_element(By.TAG_NAME, 'input').click()

    def cpok(self):
        self.driver.find_element(*self.xxok_locator).click()    # 选中产品ok

    def khxzk(self):
        self.driver.find_element(*self.kh_locator).click()
    def xzku(self):
        self.driver.find_element(*self.ku_td_locator).click()
    def khok(self):
        self.driver.find_element(*self.kuok_locator).click()  #选中关联客户ok
    def rzlr(self,lr):
        self.driver.find_element(*self.zs_locator).send_keys(lr)
    def bcal(self):
        self.driver.find_element(*self.rzbc_locator).click()

    dy_locator=(By.XPATH, '/html/body/div[5]/div[2]')
    def dy_text(self):

        return self.driver.find_element(*self.dy_locator).text
